package com.san.simulation.listener;

import org.activiti.engine.delegate.ExecutionListener;
import org.activiti.engine.impl.bpmn.parser.AbstractBpmnParseListener;
import org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity;
import org.activiti.engine.impl.pvm.process.ActivityImpl;
import org.activiti.engine.impl.pvm.process.ScopeImpl;
import org.activiti.engine.impl.pvm.process.TransitionImpl;
import org.activiti.engine.impl.util.xml.Element;
import org.activiti.engine.impl.variable.VariableDeclaration;

public class SimulationParseListener extends AbstractBpmnParseListener {

	private StartEventExecutionListener startEventExecutionListener;
	private UserManualEventExecutionListener userManualEventExecutionListener;
	private EndEventExecutionListener endEventExecutionListener;
	

	public StartEventExecutionListener getStartEventExecutionListener() {
		return startEventExecutionListener;
	}

	public void setStartEventExecutionListener(
			StartEventExecutionListener startEventExecutionListener) {
		this.startEventExecutionListener = startEventExecutionListener;
	}

	
	public UserManualEventExecutionListener getUserManualEventExecutionListener() {
		return userManualEventExecutionListener;
	}

	public void setUserManualEventExecutionListener(
			UserManualEventExecutionListener userManualEventExecutionListener) {
		this.userManualEventExecutionListener = userManualEventExecutionListener;
	}

	public EndEventExecutionListener getEndEventExecutionListener() {
		return endEventExecutionListener;
	}

	public void setEndEventExecutionListener(
			EndEventExecutionListener endEventExecutionListener) {
		this.endEventExecutionListener = endEventExecutionListener;
	}

	public void parseProcess(Element processElement,
			ProcessDefinitionEntity processDefinition) {
		// TODO Auto-generated method stub

	}

	public void parseStartEvent(Element startEventElement, ScopeImpl scope,
			ActivityImpl startEventActivity) {
		// TODO Auto-generated method stub
		
		startEventActivity.addExecutionListener(
				ExecutionListener.EVENTNAME_START, startEventExecutionListener);

		startEventActivity.addExecutionListener(
				ExecutionListener.EVENTNAME_END, startEventExecutionListener);

		System.out.println("Start Event triggered");

	}

	public void parseExclusiveGateway(Element exclusiveGwElement,
			ScopeImpl scope, ActivityImpl activity) {
		// TODO Auto-generated method stub

	}

	public void parseParallelGateway(Element parallelGwElement,
			ScopeImpl scope, ActivityImpl activity) {
		// TODO Auto-generated method stub

	}

	public void parseScriptTask(Element scriptTaskElement, ScopeImpl scope,
			ActivityImpl activity) {
		// TODO Auto-generated method stub

	}

	public void parseServiceTask(Element serviceTaskElement, ScopeImpl scope,
			ActivityImpl activity) {
		// TODO Auto-generated method stub

	}

	public void parseBusinessRuleTask(Element businessRuleTaskElement,
			ScopeImpl scope, ActivityImpl activity) {
		// TODO Auto-generated method stub

	}

	public void parseTask(Element taskElement, ScopeImpl scope,
			ActivityImpl activity) {
		// TODO Auto-generated method stub

	}

	public void parseManualTask(Element manualTaskElement, ScopeImpl scope,
			ActivityImpl activity) {
		// TODO Auto-generated method stub
		activity.addExecutionListener(
				ExecutionListener.EVENTNAME_START, userManualEventExecutionListener);

		activity.addExecutionListener(
				ExecutionListener.EVENTNAME_END, userManualEventExecutionListener);

		System.out.println("Manual Event triggered");

	}

	public void parseUserTask(Element userTaskElement, ScopeImpl scope,
			ActivityImpl activity) {
		// TODO Auto-generated method stub
		
		activity.addExecutionListener(
				ExecutionListener.EVENTNAME_START, userManualEventExecutionListener);

		activity.addExecutionListener(
				ExecutionListener.EVENTNAME_END, userManualEventExecutionListener);

		System.out.println("User Event triggered");

	}

	public void parseEndEvent(Element endEventElement, ScopeImpl scope,
			ActivityImpl activity) {
		// TODO Auto-generated method stub
		
		activity.addExecutionListener(
				ExecutionListener.EVENTNAME_START, endEventExecutionListener);

		activity.addExecutionListener(
				ExecutionListener.EVENTNAME_END, endEventExecutionListener);

		System.out.println("End Event triggered");

	}

	public void parseBoundaryTimerEventDefinition(Element timerEventDefinition,
			boolean interrupting, ActivityImpl timerActivity) {
		// TODO Auto-generated method stub

	}

	public void parseBoundaryErrorEventDefinition(Element errorEventDefinition,
			boolean interrupting, ActivityImpl activity,
			ActivityImpl nestedErrorEventActivity) {
		// TODO Auto-generated method stub

	}

	public void parseSubProcess(Element subProcessElement, ScopeImpl scope,
			ActivityImpl activity) {
		// TODO Auto-generated method stub

	}

	public void parseCallActivity(Element callActivityElement, ScopeImpl scope,
			ActivityImpl activity) {
		// TODO Auto-generated method stub

	}

	public void parseProperty(Element propertyElement,
			VariableDeclaration variableDeclaration, ActivityImpl activity) {
		// TODO Auto-generated method stub

	}

	public void parseSequenceFlow(Element sequenceFlowElement,
			ScopeImpl scopeElement, TransitionImpl transition) {
		// TODO Auto-generated method stub

	}

	public void parseSendTask(Element sendTaskElement, ScopeImpl scope,
			ActivityImpl activity) {
		// TODO Auto-generated method stub

	}

	public void parseMultiInstanceLoopCharacteristics(Element activityElement,
			Element multiInstanceLoopCharacteristicsElement,
			ActivityImpl activity) {
		// TODO Auto-generated method stub

	}

	public void parseIntermediateTimerEventDefinition(
			Element timerEventDefinition, ActivityImpl timerActivity) {
		// TODO Auto-generated method stub

	}

}
